﻿function goback() {
    history.go(-1);
}

function jsonArrayToDictionary(/*Array*/items) {
    var array = new Array();
    for (var i = 0; i<items.length;i++)
    {
        array[items[i].Key] = items[i].Value;
    }
    return array;
}

function lexicographicalOrder(first,second){
    return ((first.Value < second.Value) ? -1
         : ((first.Value > second.Value) ? 1 
         : 0));
}


function parseDate(str, format) {
    var date;
    if (!format) { 
     format = "dd.mm.yy";
    }
    try {
        date = $.datepicker.parseDate(format, str);
    } finally {
        return date;
    }
}

Date.prototype.toShortDateString = function () {
    var format = function(str){
        if (str.toString().length == 1) return '0'+str;
        return str;
    }
    return format(this.getDate()) + "." + format(this.getMonth()) + "." + this.getFullYear();
}

String.IsNullOrEmpty = function(/*string*/ value) {
    var isNullOrEmpty = true;
    if (value) {
        if (typeof (value) == 'string') {
            if (value.length > 0)
                isNullOrEmpty = false;
        }
    }
    return isNullOrEmpty;
}

function applyDatePicker() {
    $.each(arguments, function (i, item) {
        $.each($(item),function(i,textField)
        {
            $(textField).datepicker(
                {
                    changeMonth: true,
                    changeYear: true
                },$.datepicker.regional["ru"]
            );
        });
    });
}